package com.ttedu.action.manage.items;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.ttedu.base.BaseAction;
import com.ttedu.database.model.items;
import com.ttedu.database.model.types;
import com.ttedu.database.service.ItemsService;
import com.ttedu.util.Pager;

public class ItemsAction extends BaseAction{
	private items item=new items();
	private static  int pageSize; //分页显示的条数
	private Pager pager = new Pager();//分页参数
	@Autowired
	private ItemsService itemsservice;
	/**
	 * 查询页
	 * */
	@Action(value="/cas/items_index",results={ @Result(name="success",location="/WEB-INF/html/manage/items/index.jsp")})
	public String types_index(){
		String offset_=request.getParameter("pager.offset");
		int offset=Pager.getoffset(offset_);
		if(pageSize<=0){
            pageSize=20;
        }
		//查询条件
		Map paramMap = new HashMap();
		paramMap.put("offset", offset);
		paramMap.put("length", pageSize);
		List<items> listitems=itemsservice.selectItemsAll(paramMap);
		int total=itemsservice.selectItemsCount(paramMap);
		request.setAttribute("listitems", listitems);
		request.setAttribute("total", total);
		return "success";
	}
	public items getItem() {
		return item;
	}
	public void setItem(items item) {
		this.item = item;
	}
	public static int getPageSize() {
		return pageSize;
	}
	public static void setPageSize(int pageSize) {
		ItemsAction.pageSize = pageSize;
	}
	public Pager getPager() {
		return pager;
	}
	public void setPager(Pager pager) {
		this.pager = pager;
	}
	
}
